<?php

namespace App\Service\Activity;

use App\Enums\Common\NsqEnum;
use App\Enums\Mqtt\MqttEnum;
use App\Error\KfAdmin\CommonActivityError;
use App\Exceptions\KfHttpResponseException;
use App\Http\Resources\Activity\B\ActivityDetailResource;
use App\Http\Resources\Activity\B\ActivityListResource;
use App\Jobs\Activity\HandleActivityFinishStatusJob;
use App\Models\Activity\ActivityActionModel;
use App\Models\Activity\ActivityModel;
use App\Models\Activity\ActivityShopJoinModel;
use App\Models\Activity\ActivityShopRelModel;
use App\Models\Activity\ShopOrderActivityModel;
use App\Models\BaseModel;
use App\Models\Guanyuan\GuanyuanSyncShopListModel;
use App\Models\Kms\User\KmsUser;
use App\Models\Shop\ShopModel;
use App\Remote\Orm\ShopRemote;
use App\Service\BaseService;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException;
use Kuafu\Nsq\NsqPublisher;

class ActivityService extends BaseService
{
    /**
     * 霸屏MQTT推送
     * @param int $activityId
     * @return void
     * @throws Exception
     */
    public static function dominatingScreenJudge(int $activityId): void
    {
        // 业务变更，暂不需要mqtt
        return;

        // 判断霸屏是否在生效时间内
        $activity = ActivityModel::query()->find($activityId);
        if (!$activity) {
            return;
        }

        // 霸屏关闭
        if ($activity->superScreenSwitch == ActivityModel::SWITCH_OFF) {
            return;
        }

        // 霸屏结束
        if ($activity->superScreenEndTime <= time()) {
            return;
        }

        // 霸屏开始时间未到
        if ($activity->superScreenStartTime > time()) {
            $delayTime = $activity->superScreenStartTime - time();
        } else {
            $delayTime = 0;
        }

        dispatch(function () use ($activityId) {

            // 判断霸屏是否在生效时间内
            $activity = ActivityModel::query()->where('status', ActivityModel::STATUS_1)->find($activityId);
            if (!$activity) {
                return;
            }

            // 霸屏关闭
            if ($activity->superScreenSwitch == ActivityModel::SWITCH_OFF) {
                return;
            }

            // 霸屏结束
            if ($activity->superScreenEndTime <= time()) {
                return;
            }

            // 霸屏未开始
            if ($activity->superScreenStartTime > time()) {
                return;
            }

            // 判断需要霸屏的门店ids
            $needShopIds = ActivityShopRelModel::query()
                                               ->where('activityId', $activityId)
                                               ->pluck('shopId')->toArray();

            // 已参加
            $joinShopIds = ActivityShopJoinModel::query()
                                                ->where('activityId', $activityId)
                                                ->where('status', ActivityShopJoinModel::STATUS_1)
                                                ->pluck('shopId')
                                                ->toArray();

            // 未参加
            $notJoinShopIds = array_diff($needShopIds, $joinShopIds);
            if (!$notJoinShopIds) {
                return;
            }

            // TODO 结构体
            $params = [
                'type'       => 1,
                'activityId' => $activityId,
                'status'     => 1,
                'url'        => '',
                'content'    => '',
            ];
//            $params = ShopActivityService::getDominatingScreen($notJoinShopIds[0]);

            collect($notJoinShopIds)->chunk(100)->each(function ($shops) use ($params) {
                $data = $shops->map(function ($shopId) use ($params) {
                    return [
                        'shopId'      => $shopId,
                        'params'      => $params,
                        'cmd'         => 'dominatingScreen',
                        'connectType' => MqttEnum::MQTT_CLIENT_CONNECT_APP_WEB,
                    ];
                });

                // 批量推送
                (new NsqPublisher(config('nsq.default.address')))
                    ->batchPub(NsqEnum::TOPIC_MQTT_SEND, $data);
            });

        })->delay($delayTime + 1);
    }

    /**
     * 活动列表
     *
     * @param object $params
     * @return array
     */
    public static function index(object $params): array
    {
        $paginate = ActivityModel::query()
                                 ->with("shopActionRel")
                                ->when(checkFieldLen($params, "actionName"), function ($query) use ($params) {
                                    $query->whereHas("actionRel", function ($query) use ($params) {
                                        $query->where("name", "like", "%{$params->actionName}%");
                                    });
                                })
                                 ->when(checkFieldLen($params, "name"), function ($query) use ($params) {
                                     $query->where("name", "like", "%{$params->name}%");
                                 })
                                 ->when(checkFieldLen($params, "remark"), function ($query) use ($params) {
                                     $query->where("remark", "like", "%{$params->remark}%");
                                 })
                                 ->when(checkFieldLen($params, "name"), function ($query) use ($params) {
                                     $query->where("name", "like", "%{$params->name}%");
                                 })
                                 ->when(checkFieldLen($params, "activityType"), function ($query) use ($params) {
                                     $query->where("activityType", $params->activityType);
                                 })
                                ->when(checkFieldLen($params, "status"), function ($query) use ($params) {
                                    $query->where("status", $params->status);
                                })
                                 ->when(checkFieldLen($params, "startTime"), function ($query) use ($params) {
                                     $query->where(function ($query) use ($params) {
                                         $query->where("expireType", ShopOrderActivityModel::EXPIRE_TYPE_0)
                                               ->oRwhere(
                                                   function ($query) use ($params) {
                                                       $query->where("startTime", ">=",
                                                           strtotime($params->startTime))
                                                             ->where("startTime", "<=", strtotime("+1 day",
                                                                     strtotime($params->endTime)) - 1);
                                                   })
                                               ->oRwhere(
                                                   function ($query) use ($params) {
                                                       $query->where("endTime", ">=",
                                                           strtotime($params->startTime))
                                                             ->where("endTime", "<=", strtotime("+1 day",
                                                                     strtotime($params->endTime)) - 1
                                                             );
                                                   })
                                               ->oRwhere(
                                                   function ($query) use ($params) {
                                                       $query->where("endTime", ">=", strtotime("+1 day",
                                                               strtotime($params->endTime)) - 1)
                                                             ->where("startTime", "<=",
                                                                 strtotime($params->startTime));
                                                   }
                                               );
                                     });
                                 })
                                 ->when(attributeGet($params, "noFirstOrder", 0), function ($query) {
                                     $query->whereRaw(DB::raw("JSON_CONTAINS(joinRestrict, JSON_OBJECT('noFirstOrder', 1))"));
                                 })
                                 ->when(in_array("noFirstOrder", $params->joinRestrict), function ($query) {
                                     $query->whereRaw(DB::raw("JSON_CONTAINS(joinRestrict, JSON_OBJECT('noFirstOrder', 1))"));
                                 })
                                 ->when(in_array("noLogisticsFile", $params->joinRestrict), function ($query) {
                                     $query->whereRaw(DB::raw("JSON_CONTAINS(joinRestrict, JSON_OBJECT('noLogisticsFile', 1))"));
                                 })
                                 ->when(in_array("pauseShop", $params->joinRestrict), function ($query) {
                                     $query->whereRaw(DB::raw("JSON_CONTAINS(joinRestrict, JSON_OBJECT('pauseShop', 1))"));
                                 })
                                 ->when(in_array("closeShop", $params->joinRestrict), function ($query) {
                                     $query->whereRaw(DB::raw("JSON_CONTAINS(joinRestrict, JSON_OBJECT('closeShop', 1))"));
                                 })
                                 ->when(in_array("prepareShop", $params->joinRestrict), function ($query) {
                                     $query->whereRaw(DB::raw("JSON_CONTAINS(joinRestrict, JSON_OBJECT('prepareShop', 1))"));
                                 })
                                 ->when(in_array("siteSelectionShop", $params->joinRestrict), function ($query) {
                                     $query->whereRaw(DB::raw("JSON_CONTAINS(joinRestrict, JSON_OBJECT('siteSelectionShop', 1))"));
                                 })
                                 ->when(checkFieldLen($params, "superScreenSwitch"), function ($query) use ($params) {
                                     $query->where("superScreenSwitch", $params->superScreenSwitch);
                                 })
                                 ->when(checkFieldLen($params, "superScreenStartTime"),
                                     function ($query) use ($params) {
                                         $query->where(function ($query) use ($params) {
                                             $query->where(
                                                 function ($query) use ($params) {
                                                     $query->where("superScreenStartTime", ">=",
                                                         strtotime($params->superScreenStartTime))
                                                           ->where("superScreenStartTime", "<=", strtotime("+1 day",
                                                                   strtotime($params->superScreenEndTime)) - 1);
                                                 })
                                                   ->oRwhere(
                                                       function ($query) use ($params) {
                                                           $query->where("superScreenEndTime", ">=",
                                                               strtotime($params->superScreenStartTime))
                                                                 ->where("superScreenEndTime", "<=", strtotime("+1 day",
                                                                         strtotime($params->superScreenEndTime)) - 1
                                                                 );
                                                       })
                                                   ->oRwhere(
                                                       function ($query) use ($params) {
                                                           $query->where("superScreenEndTime", ">=", strtotime("+1 day",
                                                                   strtotime($params->superScreenEndTime)) - 1)
                                                                 ->where("startTime", "<=",
                                                                     strtotime($params->superScreenStartTime));
                                                       }
                                                   );
                                         });
                                     })
                                 ->when(
                                     attributeGet($params, "minPrice", 0)
                                     ||
                                     attributeGet($params, "maxPrice", 0)
                                     ||
                                     attributeGet($params, "goodsId", 0)
                                     ,
                                     function ($query) use ($params) {
                                         $query->whereHas("shopActionRel", function ($query) use ($params) {
                                             $query->when(
                                                 attributeGet($params, "minPrice", 0),
                                                 function ($query) use ($params) {
                                                     $query->where("price", ">=", $params->minPrice * 100);
                                                 }
                                             )->when(
                                                 attributeGet($params, "maxPrice", 0),
                                                 function ($query) use ($params) {
                                                     $query->where("price", "<=", $params->maxPrice * 100);
                                                 }
                                             )->when(
                                                 attributeGet($params, "goodsId", 0),
                                                 function ($query) use ($params) {
                                                     $query->where("goodsId", $params->goodsId);
                                                 }
                                             );
                                         });
                                     })
                                 ->orderByDesc("id")
                                 ->paginate($params->pageSize, ['*'], 'pageNum', $params->pageNum);

        return [
            "list"     => ActivityListResource::collection($paginate->items()),
            "count"    => $paginate->total(),
            "pageNum"  => $params->pageNum,
            "pageSize" => $params->pageSize,
        ];
    }

    /**
     * 活动新建
     *
     * @param int $uid
     * @param object $params
     * @throws Exception|GuzzleException
     */
    public static function store(int $uid, object $params)
    {
        //  获取异常门店
        list($abnormalOrderShopIds, $abnormalStatusShopIds) = self::getAbnormalShopIds(
            attributeGet($params, "joinRestrict", [])
        );

        try {
            DB::beginTransaction();
            // 活动表插入
            $activityId = ActivityModel::query()->insertGetId(
                self::buildBaseData($params)->merge([
                    "updatedByUid" => $uid,
                    "updatedAt"    => time(),
                    "createdByUid" => $uid,
                    "createdAt"    => time()
                ])->toArray()
            );

            // 获取初始化可参加门店
            $canJoinShopIds = self::getCanJoinShopIds($params, $abnormalStatusShopIds, $abnormalOrderShopIds);

            // 可参与门店数据处理写入
            collect(array_unique($canJoinShopIds))->map(function ($shopId) use ($activityId, $uid) {
                return [
                    "activityId"   => $activityId,
                    "shopId"       => $shopId,
                    "updatedByUid" => $uid,
                    "updatedAt"    => time(),
                    "createdByUid" => $uid,
                    "createdAt"    => time()
                ];
            })->chunk(500)->each(function (Collection $collection) {
                ActivityShopRelModel::query()->insert($collection->toArray());
            });

            // 活动行为表写入
            self::updateActivityActions($params->actions, $uid, $activityId);

            DB::commit();

            //  限时活动延时队列进行状态维护
            if ($params->expireType == ActivityModel::EXPIRE_TYPE_1) {
                dispatch(new HandleActivityFinishStatusJob($activityId))
                    ->delay(strtotime("+1 day", strtotime($params->endTime)) - 1 - time());
            }

        } catch (Exception $exception) {
            DB::rollBack();
            throw $exception;
        }
    }

    /**
     * 活动编辑
     *
     * @param int $uid
     * @param object $params
     * @throws Exception|GuzzleException
     */
    public static function update(int $uid, object $params)
    {
        //  获取异常门店
        list($abnormalOrderShopIds, $abnormalStatusShopIds) = self::getAbnormalShopIds(
            attributeGet($params, "joinRestrict", [])
        );

        try {
            DB::beginTransaction();
            // 活动表
            ActivityModel::query()->where("id", $params->id)->update(
                self::buildBaseData($params)->merge([
                    "updatedByUid" => $uid,
                    "updatedAt"    => time()
                ])->toArray()
            );

            // 获取初始化可参加门店
            $canJoinShopIds = self::getCanJoinShopIds($params, $abnormalStatusShopIds, $abnormalOrderShopIds);

            // 更新关联可参与门店信息
            self::updateShopRel($uid, $canJoinShopIds, $params->id);

            // 活动行为表写入
            self::updateActivityActions($params->actions, $uid, $params->id);

            DB::commit();

            //  限时活动延时队列进行状态维护
            if ($params->expireType == ActivityModel::EXPIRE_TYPE_1) {
                dispatch(new HandleActivityFinishStatusJob($params->id))
                    ->delay(strtotime("+1 day", strtotime($params->endTime)) - 1 - time());
            }

        } catch (Exception $exception) {
            DB::rollBack();
            throw $exception;
        }
    }


    /**
     * 活动详情
     *
     * @param int $id
     * @return array
     */
    public static function show(int $id): array
    {
        $row = ActivityModel::query()->where("id", $id)->with("shopActionRel")->first();
        return [
            "detail" => ActivityDetailResource::collection([$row])->getIterator()->current()
        ];
    }

    /**
     * 发布|暂停
     *
     * @param int $uid
     * @param $params
     */
    public static function status(int $uid, $params)
    {
        $row              = ActivityModel::query()->where("id", $params->id)->first();
        $canOperateConfig = [
            ActivityModel::STATUS_0 => ActivityModel::STATUS_1,
            ActivityModel::STATUS_1 => ActivityModel::STATUS_2,
            ActivityModel::STATUS_2 => ActivityModel::STATUS_1,
        ];

        if (
            !in_array($row->status, array_keys($canOperateConfig))
            ||
            $canOperateConfig[$row->status] != $params->status
        ) {
            throw new KfHttpResponseException(CommonActivityError::OPERATE_STATUS_ERROR);
        }

        ActivityModel::query()->where("id", $params->id)->update([
            "status"       => $params->status,
            "updatedByUid" => $uid,
            "updatedAt"    => time()
        ]);
    }

    /**
     * 结束
     *
     * @param int $uid
     * @param int $id
     */
    public static function finish(int $uid, int $id)
    {
        ActivityModel::query()->where("id", $id)->update([
            "status"       => ActivityModel::STATUS_3,
            "updatedByUid" => $uid,
            "updatedAt"    => time()
        ]);
    }

    /**
     * 构建基础数据
     *
     * @param object $params
     * @return Collection
     */
    public static function buildBaseData(object $params): Collection
    {
        return collect((array)$params)->except(["actions"])->map(function ($val, $key) {
            switch ($key) {
                case "joinShopIds":
                case "blackShopIds":
                case "whiteShopIds":
                case "remindCycle":
                case "feedbackExampleImages":
                    $val = json_encode($val, JSON_UNESCAPED_UNICODE);
                    break;
                case "endTime":
                case "remindEndTime":
                    $val = strtotime("+1 day", strtotime($val)) - 1;
                    break;
                case "startTime":
                case "remindStartTime":
                case "superScreenStartTime":
                case "superScreenEndTime":
                    $val = strtotime($val);
                    break;
                case "joinRestrict":
                    $val = collect(ActivityModel::JOIN_RESTRICT_TEXT)->map(function ($v, $key) use ($val) {
                        if (in_array($key, $val)) {
                            $v = 1;
                        } else {
                            $v = 0;
                        }
                        return $v;
                    })->toJson(JSON_UNESCAPED_UNICODE);
                    break;
            }
            return $val;
        });
    }

    /**
     * 获取可参与门店
     *
     * @param object $params
     * @param array $abnormalStatusShopIds 异常状态门店
     * @param array $abnormalOrderShopIds 异常订货门店
     * @return array
     */
    public static function getCanJoinShopIds(
        object $params,
        array $abnormalStatusShopIds = [],
        array $abnormalOrderShopIds = []
    ): array {
        // 获取初始化可参加门店
        if ($params->shopType == ActivityModel::SHOP_TYPE_ALL) {
            $canJoinShopIds = ShopModel::query()->pluck("id")->toArray();
        } else {
            $canJoinShopIds = $params->joinShopIds;
        }

        // 异常状态门店ids
        if ($abnormalStatusShopIds) {
            $canJoinShopIds = array_diff($canJoinShopIds, array_intersect($canJoinShopIds, $abnormalStatusShopIds));
        }

        // 未订货 || 未物流建档 门店ids
        if ($abnormalOrderShopIds) {
            $canJoinShopIds = array_diff($canJoinShopIds, array_intersect($canJoinShopIds, $abnormalOrderShopIds));
        }

        // 合并白名单门店
        if ($whiteShopIds = attributeGet($params, "whiteShopIds", [])) {
            $canJoinShopIds = array_merge($canJoinShopIds, $whiteShopIds);
        }

        if (empty($canJoinShopIds)) {
            throw new KfHttpResponseException(CommonActivityError::JOIN_SHOP_IS_EMPTY);
        }

        return array_unique($canJoinShopIds);
    }

    /**
     * 更新活动关联可参与门店信息
     *
     * @param int $uid
     * @param array $canJoinShopIds
     * @param int $activityId
     */
    public static function updateShopRel(int $uid, array $canJoinShopIds, int $activityId)
    {
        // 可参与门店数据处理写入
        $existsShopIds = ActivityShopRelModel::query()
                                             ->withoutGlobalScope("isDel")
                                             ->where("activityId", $activityId)
                                             ->pluck("shopId")
                                             ->toArray();

        $intersectionShopIds = array_intersect($existsShopIds, $canJoinShopIds);
        $delShopIds          = array_diff($existsShopIds, $intersectionShopIds);
        if ($delShopIds) {
            //  未选中数据删除
            ActivityShopRelModel::query()
                                ->withoutGlobalScope("isDel")
                                ->where("activityId", $activityId)
                                ->whereIn("shopId", $delShopIds)
                                ->update([
                                    "isDeleted" => 1,
                                    "updatedAt" => time()
                                ]);
        }

        if ($intersectionShopIds) {
            //  已存在数据状态变更
            ActivityShopRelModel::query()
                                ->withoutGlobalScope("isDel")
                                ->where("activityId", $activityId)
                                ->whereIn("shopId", $intersectionShopIds)
                                ->update([
                                    "isDeleted" => 0,
                                    "updatedAt" => time()
                                ]);
        }

        $diffShopIds = array_diff($canJoinShopIds, $intersectionShopIds);
        if ($diffShopIds) {
            // 新增数据写入
            collect(array_unique($diffShopIds))->map(function ($shopId) use ($activityId, $uid) {
                return [
                    "activityId"   => $activityId,
                    "shopId"       => $shopId,
                    "createdByUid" => $uid,
                    "createdAt"    => time()
                ];
            })->chunk(500)->each(function (Collection $collection) {
                ActivityShopRelModel::query()->insert($collection->toArray());
            });
        }
    }

    /**
     * 更新活动行为表
     *
     * @param array $actions
     * @param int $uid
     * @param int $activityId
     */
    public static function updateActivityActions(array $actions, int $uid, int $activityId)
    {
        $existsActionIds = collect($actions)->pluck("id")->filter()->toArray();
        // 活动行为表历史数据删除
        ActivityActionModel::query()
                           ->where("activityId", $activityId)
                           ->when($existsActionIds, function ($query) use ($existsActionIds) {
                               $query->whereNotIn("id", $existsActionIds);
                           })
                           ->update([
                               "isDeleted"    => BaseModel::DELETE_YES,
                               "updatedByUid" => $uid,
                               "updatedAt"    => time()
                           ]);

        // 活动行为表写入
        $fields = (new ActivityActionModel())->getFillable();
        collect($actions)->map(function ($v, $index) use ($uid, $activityId, $fields) {
            $examineUser = $goodsInfo = null;
            switch ($v["actionType"]) {
                case  ActivityActionModel::ACTION_TYPE_2:
                    if($v["examineSwitch"] == ActivityModel::SWITCH_ON){
                        $examineUser = KmsUser::query()
                                              ->whereIn("rmsUserId", $v["examineUser"])
                                              ->get()
                                              ->map(function (KmsUser $kmsUser) {
                                                  return [
                                                      "uid"      => $kmsUser->rmsUserId,
                                                      "username" => vsprintf("%s(%s)",
                                                          [$kmsUser->name, $kmsUser->nickname])
                                                  ];
                                              })->values()->toJson(JSON_UNESCAPED_UNICODE);
                    }
                    break;
                case ActivityActionModel::ACTION_TYPE_1:
                    $goodsInfo = json_encode($v["goodsInfo"], JSON_UNESCAPED_UNICODE);
                    break;
            }

            $id = attributeGet($v, "id", 0);
            if ($id > 0) {
                ActivityActionModel::query()->where("id", $id)->update(
                    collect($v)->only([
                        "name",
                        "remark",
                        "sort",
                        "hiddenSwitch",
                        "examineSwitch",
                        "groupNotificationBotName",
                        "groupNotificationBotWebhook",
                        "groupNotificationBotSecret"
                    ])->merge([
                        "examineUser"  => $examineUser,
                        "updatedByUid" => $uid,
                        "updatedAt"    => time()
                    ])->toArray()
                );
            } else {
                ActivityActionModel::query()->insert(
                    collect($v)->only($fields)->merge([
                        "activityId"   => $activityId,
                        "createdByUid" => $uid,
                        "createdAt"    => time(),
                        "updatedByUid" => $uid,
                        "updatedAt"    => time(),
                        "sort"         => $index,
                        "examineUser"  => $examineUser,
                        "goodsInfo"    => $goodsInfo
                    ])->toArray()
                );
            }
        });
    }

    /**
     * 获取异常门店数据
     *
     * @param array $joinRestrict
     * @return array
     * @throws GuzzleException
     * @throws ValidationException
     */
    public static function getAbnormalShopIds(array $joinRestrict): array
    {
        $abnormalOrderShopIds = $abnormalStatusShopIds = [];
        $shopStatusMap        = collect($joinRestrict)->map(function ($val) {
            switch ($val) {
                case "pauseShop":
                    return "暂停营业";
                case "closeShop":
                    return "闭店";
                case "prepareShop":
                    return "筹备中";
                case "siteSelectionShop":
                    return "选址中";
            }
            return null;
        })->filter()->values()->toArray();

        // 门店状态异常门店
        if ($shopStatusMap) {
            // 获取门店状态异常门店数据
            $shopCodes = GuanyuanSyncShopListModel::query()
                                                  ->whereIn("status", $shopStatusMap)
                                                  ->pluck("code")
                                                  ->toArray();

            if ($shopCodes) {
                $abnormalStatusShopIds = ShopModel::query()->whereIn("shopCode", $shopCodes)->pluck("id")->toArray();
            }
        }

        $orderShopIds = [];

        // 存在订货记录
        if (in_array(ActivityModel::JOIN_RESTRICT_1, $joinRestrict)) {
            $orderShopIds = array_merge($orderShopIds, ShopRemote::hasOrderShopLists()["shop_ids"]);
        }

        // 存在物流建档
        if (in_array(ActivityModel::JOIN_RESTRICT_2, $joinRestrict)) {
            $orderShopIds = array_merge($orderShopIds, ShopRemote::hasLogisticsFileShopLists()["shop_ids"]);
        }

        if ($orderShopIds) {
            $allShopIds           = ShopModel::query()->pluck("id")->toArray();
            $abnormalOrderShopIds = array_diff($allShopIds, array_intersect($orderShopIds, $allShopIds));
        }

        return [$abnormalOrderShopIds, $abnormalStatusShopIds];
    }

    /**
     * 更新回传时间
     *
     * @param int $activityId
     * @param int $shopId
     */
    public static function syncActivityShopJoinFeedbackStatus(int $activityId, int $shopId)
    {
        ActivityShopJoinModel::query()
                             ->where("activityId", $activityId)
                             ->where("shopId", $shopId)
                             ->update([
                                     "feedbackStatus" => ActivityShopJoinModel::FEEDBACK_STATUS_1,
                                     "feedbackTime"   => time()
                                 ]
                             );
    }
}
